<%@page import="org.swim.web.servlet.consts.Action"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="org.swim.web.utils.*"
	import="org.swim.remote.entities.*"%>
<%@page import="org.swim.remote.entities.IFriendship.Status"%>
<%@page import="org.apache.commons.lang.WordUtils"%>
<%
	IUser owner = (IUser) request.getAttribute("owner");
	IUser otherUser = (IUser) request.getAttribute("user");
%>
<div class="btn-group" style="text-align: center;">
	<a class="btn btn-primary"
		href="javascript: showNewCollaboration(<%=otherUser.getId()%>, '<%=WordUtils.capitalize(otherUser.getFullName()
					.toLowerCase())%>')">Collaborate
		with him</a>

</div>
<div class="btn-group" style="text-align: center;">
	<!-- Start friendship button -->
	<%
		if (SwimUtils.isLogged(request)) {
			IFriendship friendship = SwimUtils.getFriendship(owner,
					otherUser);
			if (friendship == null
					|| friendship.getStatus() == Status.REJECTED) {
	%>
	<a class="btn btn-primary"
		href="<%=SwimConst.Url.Servlet.PROFILE%>?a=<%=Action.REQUESTFRIENDSHIP.name().toLowerCase()%>&receiverUserId=<%=otherUser.getId()%>">Add
		to your friends</a>
	<%
		} else if (friendship.getUserByReceiverId().equals(owner)
					&& friendship.getStatus() == Status.REQUESTED) {
	%>
	<a class="btn btn-success"
		href="<%=SwimConst.Url.Servlet.PROFILE%>?a=<%=Action.ACCEPTFRIENDSHIP%>&friendshipId=<%=friendship.getId()%>">Accept
		friendship</a><a class="btn btn-danger"
		href="<%=SwimConst.Url.Servlet.PROFILE%>?a=<%=Action.REJECTFRIENDSHIP%>&friendshipId=<%=friendship.getId()%>">Reject
		friendship</a>
	<%
		} else if (friendship.getUserBySenderId().equals(owner)
					&& friendship.getStatus() == Status.REQUESTED) {
	%>
	<a class="btn btn-warning disabled" href="#">Requested friendship</a>
	<%
		}else if(SwimUtils.areFriends(owner, otherUser)){
	%>
		<a class="btn btn-info disabled" href="#">Your friend</a>
	<%
		}
		}
	%>
	<!-- End friendship button -->
</div>